//
// ********************************************************************
// * License and Disclaimer                                           *
// *                                                                  *
// * The  Geant4 software  is  copyright of the Copyright Holders  of *
// * the Geant4 Collaboration.  It is provided  under  the terms  and *
// * conditions of the Geant4 Software License,  included in the file *
// * LICENSE and available at  http://cern.ch/geant4/license .  These *
// * include a list of copyright holders.                             *
// *                                                                  *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work  make  any representation or  warranty, express or implied, *
// * regarding  this  software system or assume any liability for its *
// * use.  Please see the license in the file  LICENSE  and URL above *
// * for the full disclaimer and the limitation of liability.         *
// *                                                                  *
// * This  code  implementation is the result of  the  scientific and *
// * technical work of the GEANT4 collaboration.                      *
// * By using,  copying,  modifying or  distributing the software (or *
// * any work based  on the software)  you  agree  to acknowledge its *
// * use  in  resulting  scientific  publications,  and indicate your *
// * acceptance of all terms of the Geant4 Software license.          *
// ********************************************************************
//
//
// $Id$
// 
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

#ifndef MRunAction_h
#define MRunAction_h 1

#include "globals.hh"
#include "G4UserRunAction.hh"
#include "g4root.hh"

#include <fstream>
#include <iostream>
#include <stdio.h>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow"
#include "TFile.h"
#include "TTree.h"
#include "TBranch.h"
#pragma GCC diagnostic pop

#include <vector>
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
using namespace std;

class G4Timer;
class G4Run;
class TTree;
class TBranch;
class MRunMessenger;

class MRunAction : public G4UserRunAction
{
  public:
    MRunAction();
   ~MRunAction();

  public:
    void BeginOfRunAction(const G4Run* aRun);
    void EndOfRunAction(const G4Run* aRun);
  
    void SetFileName(G4String _fileName);

  public:
    TFile *f; 
    static TTree *OpticalPhoton;
    static int Event;
    static double Omit_x;
    static double Omit_y;
    static double Omit_z;
    static double dirX;
    static double dirY;
    static double dirZ;
    static double KEnergy;
    static double Final_x;
    static double Final_y;
    static double Final_z;
    static double ParentID;
    static double globalTime;
    static double localTime;

    static TTree *Parent;
    static int Parent_Event;
    static double Parent_Omit_KEnergy;
    static double Parent_Omit_x;
    static double Parent_Omit_y;
    static double Parent_Omit_z;
    static double Parent_dirX;
    static double Parent_dirY;
    static double Parent_dirZ;
    static double Parent_KEnergy;
    static double Parent_Final_x;
    static double Parent_Final_y;
    static double Parent_Final_z;
    static double Parent_KEnergy2;
    static double Parent_Final_x2;
    static double Parent_Final_y2;
    static double Parent_Final_z2;
    static double Parent_globalTime;
    static double Parent_localTime;

  private:
    G4Timer* timer;
    int logNum;
    fstream logfile;
    fstream loginfo;

 
    G4String fileName;

    MRunMessenger *runMessenger;

//  friend class MSteppingAction
};

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

#endif /*MRunAction_h*/
